package com.bzframework.pool;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @Author bingzhong
 * @Date 2025/7/16
 */
@Slf4j
public class CustomRejectExceptionHandler implements RejectedExecutionHandler {


    @Override
    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {

        boolean offered = executor.getQueue().offer(r);
        while (!offered) {
            log.info("rejectedExecution:{}", r);
            offered = executor.getQueue().offer(r);
        }
    }


}
